package com.yc.jpyy.driverpoint.service.impl;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;

import com.common.utils.manydatasource.HandlerDataSource;
import com.yc.jpyy.base.util.PageBean;
import com.yc.jpyy.driver.dao.DriverDao;
import com.yc.jpyy.driver.service.DriverService;
import com.yc.jpyy.driverpoint.dao.DriverPointDao;
import com.yc.jpyy.driverpoint.service.DriverPointService;
import com.yc.jpyy.drivertrain.dao.DriverTrainDao;
import com.yc.jpyy.drivertrain.service.DriverTrainService;

@Service
public class DriverPointServiceImpl  implements DriverPointService {
    
	@Autowired
	private DriverPointDao driverPointDao;


	@Override
	public int addDriverPointServer(Map<String, Object> paramsMap) throws DataAccessException {
		int ret = driverPointDao.addDriverPointDao(paramsMap);
		System.out.println(ret);
		return ret;
	}

	@Override
	public int updateDriverPointServer(Map<String, Object> paramsMap) throws DataAccessException {
		int ret = driverPointDao.updateDriverPointDao(paramsMap);
		return ret;
		
	}

	@Override
	public int delDriverPointServer(Map<String, Object> paramsMap) throws DataAccessException {
		int ret = driverPointDao.delDriverPointDao(paramsMap);
		return ret;
	}

	@Override
	public Map<String, Object> findDriverPointByIDServer(Map<String, Object> paramsMap) throws DataAccessException {
	     return driverPointDao.findDriverPointByID(paramsMap);
	}

	

	@Override
	public PageBean findDriverPointServer(Map<String, Object> paramsMap) throws DataAccessException {
		int pagenum = Integer.parseInt(paramsMap.get("pagenum").toString());
		int pagesize = Integer.parseInt(paramsMap.get("pagesize").toString());
		paramsMap.put("pagestart", (pagenum-1) * pagesize);
		
		List list = driverPointDao.findDriverPointDao(paramsMap);
		System.out.println("2222");
		System.out.println(list);
		PageBean pageBean = new PageBean();
		pageBean.setList(list);
		// 每页几条数据，默认20条
		pageBean.setPageSize(pagesize);
		// 得到数据库中的条数
		pageBean.setAllRow(this.findDriverPointServerCount(paramsMap));
		// 当前第几页，默认第一页
		pageBean.setCurrentPage(pagenum);
		// 得到一共几页
		pageBean.setTotalPage(pageBean.getTotalPage());
		// 模仿百度分页，只显示10条数据
		pageBean.paginationTool(pagenum, pageBean.getTotalPage());
		return pageBean;
	}

	@Override
	public int findDriverPointServerCount(Map<String, Object> paramsMap) throws DataAccessException {
		return driverPointDao.findDriverPointDaoCount(paramsMap);
	}

	@Override
	public int delDriverAddPointServer(Map<String, Object> paramsMap) throws DataAccessException {
		// TODO Auto-generated method stub
		return driverPointDao.delDriverAddPointDao(paramsMap);
	}

	

	
}
